package examination_online.dao;

import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.druid.util.JdbcUtils;
import examination_online.bean.User;
import examination_online.util.SpringUtils;
import org.springframework.stereotype.Repository;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * @Auther: GongXl
 * @Date: 029 08:42
 * @Description:
 */
@Repository
public class UserDao {
    public User findUserById(int id) throws SQLException {
        DruidDataSource dataSource = SpringUtils.getBean("dataSource");
        Connection conn = dataSource.getConnection();

        String sql = "SELECT * FROM e_user";
        PreparedStatement stmt = conn.prepareStatement(sql);
        stmt.setQueryTimeout(1);
        ResultSet rs = stmt.executeQuery();
        JdbcUtils.printResultSet(rs);
        rs.close();
        stmt.close();
        conn.close();
        return null;
    }
}